package com.elli0tt.session;

import com.elli0tt.config.XMLConfigBuilder;
import com.elli0tt.pojo.Configuration;

import java.io.InputStream;

/**
 * @author elli0tt
 * @version 1.0
 * @className SqlSessionFactoryBuilder.java
 * @description sql 会话接口工厂建造者
 * @createTime 2020-08-28 21:54:53
 */
public class SqlSessionFactoryBuilder {

    public SqlSessionFactory build(InputStream inputStream) throws Exception {
        // 1. dom4j 解析配置文件，将解析出来的内容封装到 Configuration
        Configuration configuration = new XMLConfigBuilder().parse(inputStream);

        // 2. 创建 SqlSessionFactory 对象
        SqlSessionFactory sqlSessionFactory = new DefaultSqlSessionFactory(configuration);
        return sqlSessionFactory;
    }

}
